{extend name=".././view/createhref.html" /}

{block name="form"}
<form class="layui-form layui-form-pane" lay-filter="myform">
  <div class="layui-form-item">
    <label for="school_id" class="layui-form-label"><span class="x-red">*</span>学校</label>
    <div class="layui-input-block">
      <select name="school_id" id="school_id" lay-verify="required">
        {volist name="list.data.school" id="vo"}
        <option value="{$vo.id}"
        {eq name="$i" value="1" }
        selected
        {/eq}
        >
        {$vo.title}
        </option>
      {/volist}
    </select>
  </div>
</div>
<div class="layui-form-item">
  <label for="ruxuenian" class="layui-form-label">
    <span class="x-red">*</span>年级
  </label>
  <div class="layui-input-block">
    <select name="ruxuenian" id="ruxuenian" lay-verify="required" class="layui-form-label">
      {foreach $list.data.nianji as $key=>$vo}
      <option value="{$vo.ruxuenian}">{$vo.nianjiname}</option>
      {/foreach}
    </select>
  </div>
</div>
<div class="layui-form-item">
  <label for="banji_id" class="layui-form-label">
    <span class="x-red">*</span>班级
  </label>
  <div class="layui-input-block" id="banji">
  </div>
</div>
<div class="layui-form-item">
  <label for="subject_id" class="layui-form-label">
    <span class="x-red">*</span>学科
  </label>
  <div class="layui-input-block" id="subject_id">

  </div>
</div>


<input type="hidden" name="kaoshi_id" id="kaoshi_id" value="{$list.set.kaoshi_id}">
<div class="layui-form-item" style="text-align: right;">
  <button  class="layui-btn" lay-filter="mysubmit" lay-submit="">
    {$list.set.butname}
  </button>
</div>
</form>
{/block}

{block name="myjs"}
<script>
  layui.use(['form','cjgl'], function(){
    var form = layui.form
    cjgl = layui.cjgl;

    // 加载页面时添加班级和学科
    addBanji();
    addSubject();

    // 监听选择按钮
    form.on('select', function(data){
      addBanji();
      addSubject();
    });

    // 添加学科列表
    function addSubject(){
      // 获取参数
      formval = form.val("myform");
      cjgl.createCheckbox('subject_id', formval, '/tools/kscy/subject', 'subject_id');
    }

    // 添加班级列表
    function addBanji(){
      // 获取参数
      formval = form.val("myform");
      cjgl.createCheckbox('banji', formval, '/tools/kscy/class', 'banji_id', 'banTitle');
    }

  });

</script>
{/block}

